#include "ioCC2530.h"

#define LED1 P1_0
unsigned char h = 0;

void initial_gpio(){
      
  P1SEL &=~0X01;
  P1DIR |= 0X01;
  LED1 = 0;
  
}
void initial_timer(){
  T1CTL |=0X01;
  PERCFG = 0X40;
  P1SEL |=0X01;
//  T1CC0L = (100000/8) & 0XFF;
//  T1CC0H = ((100000/8) & 0XFF00)>>8;
  T1CCTL2 |=0X64;
  T1CC2L = 0XFF;
  //LED1 = 1;
  T1CC2H = h;
}

void main(){
  unsigned char js = 0;
  unsigned char a = 1;
  initial_gpio();
  initial_timer();
  while(1){
        if((T1STAT & 0X04)){
          T1STAT &=0XFB;
          js++;
          if(js>=1){
            js = 0;
            if(a==1){
              h+=1;
            }else{
              h-=1;
            }
            T1CC2L = 0XFF;
            T1CC2H = h;
            if(h>=254){
              a = 2;
            }
            if(h == 0){
              a = 1;
            }
          }
        }
  }
}